package com.bwt.usermanage.utils;

import android.app.Activity;
import android.text.Editable;
import android.text.TextWatcher;
import android.widget.EditText;

/**
 * @author Tao
 * @date 2024/3/24 22:22
 */
public class HideTextWatcher implements TextWatcher {

    private EditText mView;

    private int mMaxLength;
    private Activity activity;
    public HideTextWatcher(Activity activity, EditText editText, int maxLength) {
        this.mMaxLength = maxLength;
        this.mView = editText;
        this.activity = activity;
    }

    @Override
    public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {

    }

    @Override
    public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {

    }

    @Override
    public void afterTextChanged(Editable editable) {
        if (editable.length() == mMaxLength) {
            ViewUtil.hideOneInputMethod(activity, mView);
        }
    }
}
